import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '@/views/HomeView.vue'
import Login from '@/views/login.vue'
// import { title } from 'process'
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/login',
      name: 'login',
      component: Login
    },
    {
      path: '/',
      name: 'home',
      component: HomeView,
      meta: { title: '首页' },
      // 重定向
      redirect: '/home',
      children: [
        {
          path: '/home',
          name: 'home',
          component: () => import('@/views/homes.vue'),
          meta: { title: '首页' }
        },
        {
          path: '/sync',
          name: 'sync',
          component: () => import('@/views/xitong/sync.vue'),
          meta: { title: '系统管理' },
          redirect: '/sync/user',
          children: [
            {
              path: '/sync/user',
              component: () => import('@/views/xitong/user.vue'),
              meta: { title: '用户管理' },
              name:'用户管理'
            },
            {
              path: '/sync/role',
              component: () => import('@/views/xitong/role.vue'),
              meta: { title: '角色管理' }
            },
            {
              path: '/sync/menus',
              component: () => import('@/views/xitong/menus.vue'),
              meta: { title: '菜单管理' }
            },
            {
              path: '/sync/bumen',
              component: () => import('@/views/xitong/bumen.vue'),
              meta: { title: '部门管理' }
            },
            {
              path: '/sync/zidian',
              component: () => import('@/views/xitong/zidian.vue'),
              meta: { title: '字典管理' }
            }
          ]
        }
      ]
    }
  ]
})

export default router








// // src/router/index.ts
// import { createRouter, createWebHashHistory, type RouteRecordRaw } from 'vue-router';

// export const Layout = () => import('@/layout/index.vue');

// // 静态路由
// export const constantRoutes: RouteRecordRaw[] = [
//   {
//     path: '/login',
//     component: () => import('@/views/login.vue'),
//     meta: { hidden: true }
//   },
//   {
//     path: '/',
//     component: Layout,
//     redirect: '/dashboard',
//     children: [
//       // {
//       //   path: 'dashboard',
//       //   component: () => import('@/views/dashboard/index.vue'),
//       //   name: 'Dashboard',
//       //   meta: { title: 'dashboard', icon: 'homepage', affix: true }
//       // }
//     ]
//   }
// ];

// /**
//  * 创建路由
//  */
// const router = createRouter({
//   history: createWebHashHistory(),
//   routes: constantRoutes as RouteRecordRaw[],
//   // 刷新时，滚动条位置还原
//   scrollBehavior: () => ({ left: 0, top: 0 })
// });

// /**
//  * 重置路由
//  */
// export function resetRouter() {
//   router.replace({ path: '/login' });
//   location.reload();
// }

// export default router;